package com.ruoyi.project.system.cardstylebackground.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.system.cardstylebackground.domain.CardStyleBackground;
import com.ruoyi.project.system.cardstylebackground.mapper.CardStyleBackgroundMapper;
import com.ruoyi.project.system.cardstylebackground.service.ICardStyleBackgroundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 名片样式背景Service业务层处理
 *
 * @author LCL
 * @date 2021-10-09
 */
@Service
public class CardStyleBackgroundServiceImpl implements ICardStyleBackgroundService
{
    @Autowired
    private CardStyleBackgroundMapper cardStyleBackgroundMapper;

    /**
     * 查询名片样式背景
     *
     * @param id 名片样式背景ID
     * @return 名片样式背景
     */
    @Override
    public CardStyleBackground selectCardStyleBackgroundById(String id)
    {
        return cardStyleBackgroundMapper.selectCardStyleBackgroundById(id);
    }

    /**
     * 查询名片样式背景列表
     *
     * @param cardStyleBackground 名片样式背景
     * @return 名片样式背景
     */
    @Override
    public List<CardStyleBackground> selectCardStyleBackgroundList(CardStyleBackground cardStyleBackground)
    {
        return cardStyleBackgroundMapper.selectCardStyleBackgroundList(cardStyleBackground);
    }

    /**
     * 新增名片样式背景
     *
     * @param cardStyleBackground 名片样式背景
     * @return 结果
     */
    @Override
    public int insertCardStyleBackground(CardStyleBackground cardStyleBackground)
    {
        cardStyleBackground.setId(UUID.randomUUID().toString().replace("-",""));
        cardStyleBackground.setCreatedTime(new Date());
        return cardStyleBackgroundMapper.insertCardStyleBackground(cardStyleBackground);
    }

    /**
     * 修改名片样式背景
     *
     * @param cardStyleBackground 名片样式背景
     * @return 结果
     */
    @Override
    public int updateCardStyleBackground(CardStyleBackground cardStyleBackground)
    {
        return cardStyleBackgroundMapper.updateCardStyleBackground(cardStyleBackground);
    }

    /**
     * 删除名片样式背景对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCardStyleBackgroundByIds(String ids)
    {
        return cardStyleBackgroundMapper.deleteCardStyleBackgroundByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除名片样式背景信息
     *
     * @param id 名片样式背景ID
     * @return 结果
     */
    @Override
    public int deleteCardStyleBackgroundById(String id)
    {
        return cardStyleBackgroundMapper.deleteCardStyleBackgroundById(id);
    }

    @Override
    public CardStyleBackground findCardStyleBackgroundByMemberId(String memberId) {
        return cardStyleBackgroundMapper.findCardStyleBackgroundByMemberId(memberId);
    }

    @Override
    public Integer maxSort(String memberId) {
        return cardStyleBackgroundMapper.maxSort(memberId);
    }

    @Override
    public CardStyleBackground findBackgroundByMemberIdAndSort(String memberId) {
        return cardStyleBackgroundMapper.findBackgroundByMemberIdAndSort(memberId);
    }
}
